package com.oig.sys.msg.dao;

import com.oig.sys.msg.entity.TbExportTask;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
@author wuxl
*/
public interface ITbExportTaskDao extends JpaRepository<TbExportTask, Integer> {

	@Query("from TbExportTask t where t.id=:id")
	TbExportTask getExportTaskById(@Param("id") Integer id);


	@Query("select count(t) from TbExportTask t where t.createUserId=:userId and t.status='02'  and t.delFlag='0' ")
	Integer findUnDownSizeByUserId(@Param("userId") Integer userId);

	@Query("select count(t) from TbExportTask t where t.id in(:idList) and t.createUserId=:userId")
	Integer countByUserId(@Param("idList") List<Integer> idList, @Param("userId") Integer userId);

	@Modifying
	@Query("update TbExportTask t set t.delFlag='1' where t.id in(:idList) ")
	void updateDelByIdList(@Param("idList") List<Integer> idList);

}
